home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / tiff.566 < prev    next >
Text File  |  1992-02-06  |  3KB  |  55 lines

  1. {\rtf0\ansi{\fonttbl\f2\fnil Times-Roman;\f3\fmodern Courier;\f1\fswiss Helvetica;}
  2. \paperw11760
  3. \paperh7200
  4. \margl120
  5. \margr120
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f2\b0\i0\ul0\fs28 TIFF DPI resolution NXBitmapImageRep scanning conversion formats\
  8.     \
  9. Q:  How is DPI information stored in a TIFF file?  How do I create a TIFF file with DPI information?  How do I read it back?\
  10.  
  11. \i     \
  12.  
  13. \i0 A:  TIFF files usually contain explicit DPI; they don't contain an explicit size.   So you determine size from DPI & pixel count.  NXBitmapImageRep (new in release 2.0) contains an explicit size & pixel count; so you determine DPI from these two.\
  14. \
  15. For example, if you were writing an app which scans images and were to scan in an 8  1/2" by 11" image at 300 DPI you would set the pixels to be 300 x 8.5 for the width and 300 x 11 for the height.  You would set the size to be 72 x 8.5 for the horizontal and 72 x 11 for the vertical assuming that 72 points == 1 inch. \
  16.  
  17. \i \
  18.  
  19. \i0 NXBitmapImageRep sizes are in points. From all this, the formulas for DPI become (POINTSPERINCH is 72, the PS standard):\
  20.  \
  21.  
  22. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\fc0      xRes = (pixelsWide*POINTSPERINCH) / size.width;\
  23.      yRes = (pixelsHigh*POINTSPERINCH) / size.height;\
  24.  
  25. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 \
  26. The units work out to be\
  27. \
  28.     resolution = (pixels * points / inch) / (points) = pixels / inch\
  29.  
  30. \i \
  31.  
  32. \i0 When reading the TIFF file back using 
  33. \f3\fs24 initFromFile:
  34. \f2\fs28  and then drawing that file, it will "do the right thing" and read it back at the correct size.  That size can be further modified using the NXBitmapImageRep method 
  35. \f3\fs24 setSize:
  36. \f2\fs28 .  This does not actually modify the bits but just changes the size at which the image is displayed.\
  37. \
  38. A useful utility when examining TIFF images is "tiffutil -info <file>" from a Terminal.  This will read the header on the TIFF file and interpret useful information.  Do a "man tiffutil" for more information.\
  39. \
  40. For those who are very brave and wish to decrypt the mysteries of the TIFF format you can obtain a copy of Sam Leffler's TIFF library package by anonymous ftp at the following site:\
  41. \
  42.     ucbvax.berkeley.edu   (pub/tiff/v2.2.tar.Z)\
  43.     \
  44. In the event that you choose to use Sam's TIFF library to write your own tags into the header of a TIFF file, that TIFF file will not be understood by the appkit.  However, if you have TIFF files generated on another platform which have tags not understood by the appkit a good conversion mechanism would be to use Sam's library to read the files and to write them out using NXBitmapImageRep methods in the appkit.\
  45. \
  46. See also:  tiff.426\
  47. \
  48. \
  49. QA566                \
  50. \
  51. Not valid for 1.0\
  52. Valid for 2.0\
  53. \
  54.  
  55.